<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-07-01 11:52:50
 * @LastEditors: charles
 * @LastEditTime: 2021-08-01 14:08:13
-->
<template>
  <div class="details">
    <h2 style="text-align:center">{{data.title}}</h2>
    <div class="wrapper" v-html="data.content"></div>
      <el-row>
        <el-button type="primary" plain style="position:relative;left:50%" @click="thumbUp(data.id)">点赞</el-button>
      </el-row>
  </div>
</template>
<script>
import {get} from '../utils/request'
export default {
  data(){
    return{
      id:'',
      data:[],
    }
  },
  methods: {
    // 点赞
    thumbUp(id){
      get('/index/article/thumbUp',{id:id}).then((res)=>{
        if(res.status == 200){
          this.$message({
          message: res.message,
          type: 'success'
        });
      }else{
          this.$message({
            type:'error',
            message:res.message
          })
        }
      })
    },
    // 查询咨询详情
    findArticleDetails(){
      get('/index/article/findById?id='+this.id).then((res)=>{
        if(res.status == 200){
          this.data = res.data
        }else{
          this.$message({
            type:'error',
            message:res.message
          })
        }
      })
    }
  },
  created(){
    // 拿到从上一个页面传过来的id值
    this.id = this.$route.query.id
    // 调用查询project详情的方法
    this.findArticleDetails()
  },
}
</script>
<style lang="scss" scope>
  .details{
    .wrapper{
      width: 70%;
    }
  }
</style>